 constructor(viewer, options) {
    this.viewer = viewer;
    this.position = Cesium.defaultValue(
      options.position,
      Cesium.Cartesian3.ZERO
    );
    this.label = Cesium.defaultValue(options.label, "label");
    this.isShow = Cesium.defaultValue(options.isShow, true);
    this.color = Cesium.defaultValue(options.color, "#ff0000");
    this.scaleByDistance = Cesium.defaultValue(
      options.scaleByDistance,
      new Cesium.NearFarScalar(1000, 1, 20000, 0.4)
    );
    this.attr = Cesium.defaultValue(options.attr, {});
    this.popupType = Cesium.defaultValue(options.type, "marker");
    this.offset = Cesium.defaultValue(options.offset, [0, 0]);
    this.popupRoutes = {
      marker: () => import("./MakerTemplate.vue"),
      carPopup: () => import("./PopupCar.vue"),
    };

    this.isDisplay = true;
  }

  // 外部修改坐标
  changePosition(position) {
    this.position = position;
  }

  addLabel() {
    // 如果在模板中找不到对应的，直接返回
    if (!this.popupRoutes[this.popupType]) {
      return;
    }
    this.popupRoutes[this.popupType]().then((res) => {
      //创建模板 label: this.properties.attr.label
      this.vmInstance = createVNode(res.default, {
        label: this.label,
        color: this.color,
        position: this.position,
        attr: this.attr,
      }); //根据模板创建一个面板
      this.mountNode = document.createElement("div");
      render(this.vmInstance, this.mountNode);
      this.viewer.cesiumWidget.container.appendChild(this.mountNode); //将字符串模板生成的内容添加到DOM上
      this.addPostRender();
      this.vmInstance.el.style.display = this.isShow ? "block" : "none";
      return this.vmInstance.el;
    });
  }
  